/*
 * =====================================================================================
 *
 *       Filename:  test.c
 *
 *    Description:  python传值c,c改值后传回Python
 *    				gcc -o test.so -shared -fPIC test.c
 *
 *        Version:  1.0
 *        Created:  12/11/2014 05:34:09 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  yangkun
 *          Email:  xyyangkun@163.com
 *        Company:  FreedomIsNotFree.com
 *
 * =====================================================================================
 */
#include <stdio.h>
#include <string.h>
int return_value(int *val)
{
	printf("\nin c code %s %d :val:%d\n",__FUNCTION__, __LINE__,*val);
	*val = 10;
	return 10;
}
char * return_str(char *in_str, int str_len)
{
	static char str[100]="this test c trans str\n";
	static char return_str[100]="this test c return str\n";
	printf("in c code\n%s %d str:%s\n",__FUNCTION__, __LINE__, in_str);
	printf("lenstr:%d, arg_len：%d\n",(int)strlen(in_str), str_len);
	printf("%s \n %s \n",str, return_str);
	strcpy(in_str, (char *)str);
	return return_str;
}

struct POINT
{
	int x;
	int y;
};
struct POINT return_point(struct POINT point)
{
	static struct POINT p1={10,20};
	printf("***********in c***************\n");
	printf("recv point form python:\n");
	printf("x:%d,y:%d\n",point.x,point.y);

	printf("return to python:\n");
	printf("x:%d,y:%d\n",p1.x,p1.y);
	printf("***********in c***************\n");
	return p1;
}

struct POINT *return_point_p(struct POINT *point)
{
	static struct POINT p1={100,200};
	printf("***********in c***************\n");
	printf("recv point_p form python:\n");
	printf("x:%d,y:%d\n",point->x,point->y);

	printf("return to python:\n");
	printf("x:%d,y:%d\n",p1.x,p1.y);
	printf("***********in c***************\n");
	return &p1;
}
